package anaydis.animation.model;

import java.util.List;
import java.util.ArrayList;

public class TriangleDataModel
        extends SortDataModel

{
    private boolean inverted;

    public TriangleDataModel(boolean inverted)
    {
        this.inverted = inverted;
    }

    public List<Integer> create(int size)
    {
        final List<Integer> result = initializeEmptyList(size);

        final int m = size / 2;

        for (int i = 0; i < m; i++)
        {
            if (inverted) {
                result.set(i, size - i * 2 - 1);
            }
            else {
                result.set(i, i * 2 + 1);
            }

            result.set(size - i - 1, result.get(i) + 1);
        }

        return result;
    }

    public String toString()
    {
        return inverted ? "Inverted Triangle" : "Triangle";
    }
}